/*
 * This file is part of the openHiTLS project.
 *
 * openHiTLS is licensed under the Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *
 *     http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */

#ifndef HITLS_APP_ASN1PARSE_H
#define HITLS_APP_ASN1PARSE_H
#include <stdint.h>
#include <stddef.h>
#include "bsl_asn1.h"
#include "bsl_uio.h"
#ifdef __cplusplus
extern "C" {
#endif

typedef struct {
    const char *name;
    BSL_ASN1_Template *templ;
    const char **fieldNames;
    HITLS_NamedAsn1Template **childTemplates;
} HITLS_NamedAsn1Template;

int32_t HITLS_Asn1ParseMain(int argc, char *argv[]);

int32_t Asn1ParseInfo(BSL_UIO *outUio, uint32_t offset, uint32_t depth, uint32_t hl, uint32_t len,
                           const char* p, const char* tname);        

int32_t Asn1ParseFormat(BSL_UIO *outUio, BSL_ASN1_Buffer *buff, const char* fname,
                        uint32_t dlimit, uint32_t indent, uint32_t dump);

int32_t Asn1ParseDump(BSL_UIO *outUio, const uint8_t *encode, uint32_t encLen,
                      uint32_t dlimit, uint32_t indent, uint32_t dump/*, OID先留着不实现 */);

int32_t Asn1ParseItem(BSL_UIO *outUio, HITLS_NamedAsn1Template *tplt, uint8_t *encode, uint32_t encLen,
                      uint32_t dlimit, uint32_t indent, uint32_t dump/*, OID先留着不实现 */);

#ifdef __cplusplus
}
#endif
#endif
